function uploader_init()
{
	$('.uploader').unbind('change');
	$('.uploader').change(function(){
		$(this).upload('/web-admin/uploader.php', function(res){
			if (res == ''){
				return false;
			}
			var json = $.parseJSON(res);
			$('#' + json['code']).val(json['cache']);
			$('#preview_' + json['code']).html('<img src="/web-admin/uploader.php?cache=' + json['cache'] + '"/>');
                        $('#filename_' + json['code']).html(json['filename']);
                        $('#original_' + json['code']).val(json['filename']);
		});
	});
}
$(document).ready(function(){
	uploader_init();
});